﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="TimKen.Web.Admin.ProductCategory.Test" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentLinkAction" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentTitle" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentMain" runat="server">
    <script type="text/javascript">
            $(document).ready(function () {
                $('#tt').treegrid({
                    url: 'ProductCategory_Test.aspx?rnd='+Math.random(),
                    idField: 'CategoryID',
                    treeField: 'CategoryName',
                    columns: [[
                        { title: 'Task Name', field: 'CategoryName', width: 260 },
                        { field: 'CategoryID', title: 'Manager', width: 540, align: 'right', formatter: Config }
                    ]]
                });
            });

            function Config(value) {
                var obj = $('#tt').treegrid("find", value);
                var _val = "";
                if (value) {
                    if (value > 0) {
                        _val = _val + EditConfig(value);
                        _val = _val + " | " + SortConfig(value);

                        if (obj.Config == "true") {
                            _val = _val + " | " + AddConfig(value);
                        }
                        else {
                            _val = _val + " | " + AppConfig(value);
                        }
                        if (obj.state == "open")
                            _val = _val + " | " + DeleteConfig(value);
                    }
                    else {
                        if (obj.Config) {
                            _val = _val + AddConfig(value);
                        }
                    }
                }
                return _val;
            }

            function ClickCell(field, row) {
                alert(field + "," + row);
            }

            function EditConfig(value) {
                return "<a href=\"../ProductCategory/ProductCategory_Add.aspx?categoryId=" + value + "&Act=Edit\" target=\"_blank\">编辑</a>";
            }

            function AddConfig(value) {
                return "<a href=\"../ProductCategory/ProductCategory_Add.aspx?categoryId=" + value + "&Act=Add\" target=\"_blank\">新增子类</a>";
            }

            function DeleteConfig(value) {
                return "<a href=\"../ProductCategory/ProductCategory_Add.aspx?categoryId=" + value + "&Act=Delete\" target=\"_blank\">删除</a>";
            }

            function AppConfig(value) {
                return "<a href=\"../ProductCategory/ProductCategory_Add.aspx?categoryId=" + value + "&Act=App\" target=\"_blank\">设置</a>";
            }

            function SortConfig(value) {
                return "<a href=\"../ProductCategory/ProductCategory_Add.aspx?categoryId=" + value + "&Act=Sort\" target=\"_blank\">排序</a>";
            }

    </script>
    <table id="tt" style="width:900px;height:400px"></table>
    <%--<table title="Products" class="easyui-treegrid" style="width:700px;height:300px"  
            url="ProductCategory_Test.aspx"  
            rownumbers="true"  
            idField="id" treeField="name">  
        <thead>  
            <tr>  
                <th field="name" width="250">Name</th>  
                <th field="quantity" width="100" align="right">Quantity</th>  
                <th field="price" width="150" align="right" formatter="formatDollar">Price</th>  
                <th field="total" width="150" align="right" formatter="formatDollar">Total</th>  
            </tr>  
        </thead>  
    </table>  
    <script>  
        function formatDollar(value){  
            if (value){  
                return '$'+value;  
            } else {  
                return '';  
            }  
        }  
    </script>--%>
</asp:Content>
